import { fetchBodyPost, fetchGet, fetchPost } from '@/utils/ReqInstance/axios';
/**
 * API相关接口
 */
export default {
  /** 注册-登录部分 */
  // 后端生成随机数
  GenRandom: (params: any) => {
    return fetchPost('/users/randomNumber', params);
  },
  // 登录
  Login: (params: any) => {
    return fetchPost('/users/login', params, true);
  },
  // 退出登录
  Logout: () => {
    return fetchPost('/users/logout', {});
  },
  // 初始化设备-注册用户
  InitDevice: (params: any) => {
    return fetchPost('users/init', params, true);
  },

  /** 用户管理 */
  // 获取用户管理数据
  GetUsersData: (params: any) => {
    return fetchPost('/users/users_info', params);
  },
  // 添加用户
  AddUser: (params: any) => {
    return fetchPost('/users/add', params);
  },
  // 修改用户密码
  ChangeUserPin: (params: any) => {
    return fetchPost('/users/user_change_password', params);
  },
  // 删除用户
  DeleteUser: (params: any) => {
    return fetchPost('/users/user_delete', params);
  },

  /** 设备管理 */
  // 获取设备信息
  GetDeviceInfo: (params: any) => {
    return fetchPost('/device/info', params);
  },
  // 获取设备状态
  GetDeviceStatus: (params: any) => {
    return fetchPost('/device/status', params);
  },
  // 设备状态-修改算法运行开关
  ChangeMethodRunState: (params: any) => {
    return fetchPost('/device/set_algorithm_status', params);
  },
  // 设备状态-机箱状态复位
  ChassisReset: (params: any) => {
    return fetchPost('/device/invasion_reposition', params);
  },
  // 设备状态-替换电池
  ReplaceBattery: (params: any) => {
    return fetchPost('/device/battery_reposition', params);
  },
  // 获取设备配置
  GetDeviceConfig: (params: any) => {
    return fetchPost('/device/setting', params);
  },
  // 获取设备日志等级
  GetLogLevel: () => {
    return fetchPost('/device/get_log_class', {});
  },
  // 设置日志等级
  SetLogLevel: (params: any) => {
    return fetchPost('/device/set_log_class', params);
  },
  // 设备自检
  DeviceCheck: () => {
    return fetchPost('/device/self_test', {});
  },
  // 修改设备自检周期
  ChangeCheckCycle: (params: any) => {
    return fetchPost('/device/set_interval', params);
  },
  // 获取当前自检周期
  GetCheckCycle: () => {
    return fetchPost('/device/get_interval', {});
  },
  // 获取上次自检时间
  GetCheckTime: () => {
    return fetchPost('/device/self_test_time', {});
  },
  // 设备恢复出厂设置
  ResetDevice: (params: any) => {
    return fetchPost('/device/reset', params);
  },

  /** 密钥管理 */
  // 获取密钥管理数据
  GetKeyManageData: (params: any) => {
    return fetchPost('/keys/infos', params);
  },
  // 修改密钥管理数据访问控制码
  ChangeKeyLogAccessCode: (params: any) => {
    return fetchPost('/keys/update', params);
  },
  // 创建密钥数据
  CreateKey: (params: any) => {
    return fetchPost('/keys/add', params);
  },
  // 删除密钥管理数据
  DeleteKeyLog: (params: any) => {
    return fetchPost('/keys/delete', params);
  },
  // 备份密钥管理数据
  BackupKeyLog: (params: any) => {
    return fetchBodyPost('/keys/export', params);
  },
  // 清空会话密钥
  ClearSessionKey: (params: any) => {
    return fetchPost('/keys/sess_clear', params);
  },
  /** 日志管理 */
  // 获取日志数据
  GetLogData: (params: any) => {
    return fetchPost('/logs/infos', params);
  },
  // 获取接口日志数据
  GetInterfaceLog: (params: any) => {
    return fetchPost('/interface-log', params);
  },
  // 获取管理日志数据
  GetManageLog: (params: any) => {
    return fetchPost('/manage-log', params);
  },
  // 获取系统日志数据
  GetSystemLog: (params: any) => {
    return fetchPost('/system-log', params);
  },
  // 清空日志
  ClearLog: (params: any) => {
    return fetchPost('/logs/clear', params);
  },
  // 导出日志
  ExportLog: (params: any) => {
    return fetchPost('/logs/export_file', params);
  },
  /** 文件管理 */
  // 获取文件空间
  GetFileSpace: () => {
    return fetchPost('/device/files_space', {});
  },
  // 初始化文件空间
  InitializeFileSpace: (params: any) => {
    return fetchPost('/device/files_clear', params);
  },

  /** 访问控制 */
  // 查看白名单
  GetWhiteList: (params: any) => {
    return fetchPost('/white_list/infos', params);
  },
  // 添加白名单
  AddWhiteList: (params: any) => {
    return fetchPost('/white_list/add', params);
  },
  // 删除白名单
  DeleteWhiteList: (params: any) => {
    return fetchPost('/white_list/delete', params);
  },

  /** 以下接口为测试接口-没有使用 */
  // 设备初始化
  Register: (params: any) => {
    return fetchPost('/init', params);
  },
  // 枚举设备名称
  GetEnumDevice: () => {
    return fetchPost('/device/enum-device', {});
  },
  // 导入密钥数据
  ImportKey: (params: any) => {
    return fetchPost('/keys/import', params);
  },
  // 恢复密钥管理数据
  RecoveryKeyLog: (params: any) => {
    return fetchPost('/keys/recovery', params);
  },
  // 添加黑名单
  AddBlackList: (params: any) => {
    return fetchPost('/black-list/add', params);
  },
  // 删除黑名单
  DeleteBlackList: (params: any) => {
    return fetchPost('/black-list/delete', params);
  },
  // 获取黑名单数据
  GetBlackListData: (params: any) => {
    return fetchPost('/black-list', params);
  },
  GetInitedStatus: () => {
    return fetchGet('/device/device_status', {});
  },
};
